<template>
    <div>
        <Card>
            <p slot="title">
                企业认证审核
            </p>
            <div>
                <Form class="step-form" ref="userData" :model="userData" :label-width="100">
                   <Row span="12">
                        <i-col span="12" >
                            <FormItem label="企业名称：" label-position="left" :label-width="150">
                                <Input  :disabled="hasSubmit" v-model="userData.name" type="text" placeholder="输入数据不能为空" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row span="12">
                        <i-col span="12" >
                            <FormItem label="法人身份证号：" label-position="left" :label-width="150">
                                <Input :disabled="hasSubmit" v-model="userData.legalCard" type="text" placeholder="输入数据不能为空" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row span="12">
                        <i-col span="12" >
                            <FormItem label="法人姓名：" label-position="left" :label-width="150">
                                <Input :disabled="hasSubmit" v-model="userData.legalPerson" type="text" placeholder="输入数据不能为空" />
                            </FormItem>
                        </i-col>
                    </Row>

                    <!--<Row span="12">
                        <i-col span="12" >
                            <FormItem label="手机号：" label-position="left" :label-width="150">
                                <Input :disabled="hasSubmit" v-model="userData.legalPhone" type="text" placeholder="手机号不能为空" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row span="12">
                        <i-col span="12" >
                            <FormItem label="营业执照号：" label-position="left" :label-width="150">
                                <Input :disabled="hasSubmit" v-model="userData.businessLicense" type="text" placeholder="营业执照号不能为空" />
                            </FormItem>
                        </i-col>
                    </Row>-->
                    <Row span="12">
                        <i-col span="12" >
                            <FormItem label="申请人真实姓名：" label-position="left" :label-width="150">
                                <Input :disabled="hasSubmit" v-model="userData.applyRealName" type="text"  />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row span="12">
                        <i-col span="12" >
                            <FormItem label="申请人手机号：" label-position="left" :label-width="150">
                                <Input :disabled="hasSubmit" v-model="userData.applyMobile" type="text" />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row span="12">
                        <i-col span="12" >
                            <FormItem label="申请人身份证号：" label-position="left" :label-width="150">
                                <Input :disabled="hasSubmit" v-model="userData.applyCarNum" type="text"  />
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row span="12">
                        <i-col span="10">
                            <FormItem label="营业执照图片：" label-position="left" :label-width="150">
                                <img v-if="userData.businessLicenseUrl !== ''" :src="userData.businessLicenseUrl" height="200" width="200">
                            </FormItem>
                        </i-col>
                    </Row>
                    <!--<Row span="12">
                        <i-col span="10">
                            <FormItem label="门头照：" label-position="left" :label-width="150">
                                <img v-if="userData.doorHeaderUrl !== ''" :src="userData.doorHeaderUrl" height="200" width="200">
                            </FormItem>
                        </i-col>
                    </Row>-->
                    <Row span="12">
                        <i-col span="10">
                            <FormItem label="身份证正面：" label-position="left" :label-width="150">
                                <img v-if="userData.cardUrl !== ''" :src="userData.cardUrl" height="200" width="200">
                            </FormItem>
                        </i-col>
                    </Row>
                    <Row span="12">
                        <i-col span="10">
                            <FormItem label="身份证背面：" label-position="left" :label-width="150">
                                <img v-if="userData.cardBackUrl !== ''" :src="userData.cardBackUrl" height="200" width="200">
                            </FormItem>
                        </i-col>
                    </Row>
                    <FormItem >
                        <Button @click="auditSuccess" style="width:100px;" type="primary">审核成功</Button>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <Button @click="auditFail" style="width:100px;" >审核失败</Button>
                    </FormItem>
                </Form>
            </div>
        </Card>
        <Modal
            v-model="modal1"
            title="审核失败"
            @on-ok="ok"
            @on-cancel="cancel">
            <Input v-model="failreason" type="textarea" :rows="4" placeholder="请输入审核失败原因"/>
        </Modal>
    </div>
</template>


<script>
import ajax from '../../../libs/axios.js'
export default {
    name: 'addUser',
    data () {
        return {
            modal1:false,
            testModelShow:false,
            symptomList:[],
            selectModel:[],
            userData: {
                id:'',
                name:'',
                legalPerson:'',
                legalCard:'',
                legalPhone: '',
                businessLicense:'',
                businessLicenseUrl:'',
                cardUrl:'',
                cardBackUrl:'',
                doorHeaderUrl:'',
                applyRealName:'',//申请人真实姓名
                applyMobile:'',//申请人手机号
                applyCarNum:'',//申请人身份证号码
                uid:''//申请人的Id
            },
            hasSubmit: true,
            // 图片上传
            file: null,
            status: 'wait',
            uploadLoading: false, // 上传图片时候的加载效果,
            failreason:"",//审核失败
            userId:-1,//当前登陆人员的Id
            userName:"",//当前登陆人员的姓名
            id:-1,
            uid:''
        }
    },
    methods: {
        // 数据初始化
        init () {
            this.userId = window.localStorage.getItem('userId')
            this.userName = window.localStorage.getItem('userName')
            this.$store.commit('setActiveName', 'partyindex');
            let id = this.$route.params.id;
            debugger;
            this.uid = this.$route.params.userId;
            this.id = id;
            this.personalInfo(id);
        },
        // 获取数据
        personalInfo(id){
            debugger;
            let _that = this;
            let url = 'adminlogin/selectPartyInfoByUserId'
            let data = {
                id: _that.uid
            }
            ajax.formRes(url, data).then(res => {
                //success
                if(200 == res.code){

                    _that.userData = res.data;
                }else{
                    _that.$Message.success('数据原因，请联系管理员。')
                }
            }).catch(res => {
                _that.$Message.success('数据原因，请联系管理员。')
                console.log('有错误信息')
                // fail
            })
        },
        // 审核成功相关数据操作
        auditSuccess () {
            //登陆成功，存储审核信息。
            this.addAuditInfo(2);
        },
        auditFail () {
            // this.$router.push({
            //     name: 'diseaseIndex'
            // })
            //this.emptyData()
            this.modal1 = true;
        },
        ok () {
            let _that = this;
            if(_that.failreason == ""){
                _that.$Modal.warning({
                    title: '警告',
                    content: '失败原因不能为空！！！'
                });
            }else{
                _that.addAuditInfo(3);
            }

        },
        cancel () {
            //this.$Message.info('点击了取消');
        },
        // 存储审核信息
        addAuditInfo(status){

            let _that = this;
            let url = 'adminlogin/addAuditInfo'
            let data = {
                uid: _that.uid,
                pId: _that.id,
                type:2,
                status:status,
                remark:_that.failreason,
                auditName:_that.userName
            }
            ajax.formRes(url, data).then(res => {
                //success
                if(200 == res.code){
                   _that.$Message.success('审核成功，将为您跳转到首页。')
                   setTimeout(function () {
                        let argu = {}
                        _that.$router.push({
                            name: 'partyindex',
                            params: argu
                        })
                    }, 1500)
                }else{
                    _that.$Message.success('数据原因，请联系管理员。')
                }
            }).catch(err => {
                _that.$Message.success('数据原因，请联系管理员。')
                console.log('有错误信息')
            })
        }

    },
    created: function () {
        this.init()
    },
    activated: function () {
        //this.init()
    }
}
</script>
<style>
    .demo-upload-list-cover{
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,.6);
    }
    .card-upload:hover .demo-upload-list-cover{
        display: block;
    }
    .demo-upload-list-cover i{
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }
    .demo-spin-icon-load{
        animation: ani-demo-spin 1s linear infinite;
    }
    @keyframes ani-demo-spin {
        from { transform: rotate(0deg);}
        50%  { transform: rotate(180deg);}
        to   { transform: rotate(360deg);}
    }
    .demo-spin-col{
        height: 100px;
        position: relative;
        border: 1px solid #eee;
    }
</style>

